<?php
include('global.php');
//require_once "functions.php";
session_start();
if($cusername !=""){
        //login_validate();
	header("Location:main.php");
}else{
	if(($username != "") and ($password!= "")){
		$username = htmlentities(trim($username), ENT_QUOTES);
		$password = htmlentities(trim($password), ENT_QUOTES);
		$sql = "select * from qry_user where user_name='$username' and password='$password'";
		$result=dbresult($sql);

		$jumlah=pg_num_rows($result);
		if($jumlah > 0){
			$r = pg_fetch_array($result,0);
			$divisi_kode = $r[divisi_kode];
			setcookie("cusername",$username);
			setcookie("cpassword",$password);
			setcookie("ckabag",$nama_kabag);
			setcookie("cjabatan",$nama_jabatan);
			setcookie("coperator",$operator);
			setcookie("cuserid",$r[user_id]);
			setcookie("cakses",$r[level_akses]);
			setcookie("cnama",trim($r[first_name])." ".trim($r[last_name]));
			if($divisi_id<>44){
				$sql_divisi = "select * from tbl_divisi where divisi_kode='$divisi_kode'";
				$result_d=dbresult($sql_divisi);
				$r_x = pg_fetch_array($result_d,0);
				setcookie("ckonsolidasi",false);
				setcookie("cdivisi_name",$r_x[divisi_name]);
				setcookie("cdivisi_kode",$r_x[divisi_kode]);
				setcookie("cdivisi_kode_asli",$r_x[divisi_kode]);
				setcookie("cdivisi_id",$r_x[divisi_id]);
				setcookie("cdivisi_account",$r_x[divisi_account]);
			}else{
				setcookie("ckonsolidasi",true);
				setcookie("cdivisi_name","Konsolidasi");
				setcookie("cdivisi_kode","%%%");
				setcookie("cdivisi_id","44");
				setcookie("cdivisi_account","%%%");
			}
			header("Location:index.php");
		}else{
			$pesan = "Hak Akses Ditolak";
		}
	}
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SIM TAX PT Nindya Karya</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="css/blue.css" media="screen, projection, tv" />
<link rel="shortcut icon" href="css/img/favicon.gif" />
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<style type="text/css">
/*<!--
.title {
	font-family: Tahoma, Arial, Helvetica, sans-serif;
	font-size: 11px;
	font-weight: bold;
	color: #0000ff;
	border-bottom-width: 1px;
	border-top-style: none;
	border-right-style: none;
	border-bottom-style: dotted;
	border-left-style: none;
	border-bottom-color: #0000ff;
}
.tbody {
	font-family: Tahoma, Arial, Helvetica, sans-serif;
	font-size: 11px;
	font-weight: bold;
	color: #053B75;
}
.field {
	font-family: Tahoma, Arial, Helvetica, sans-serif;
	font-size: 11px;
	color: #0000ff;
	background-color: #ffffff;
	padding: 2px;
	border: 1px solid #0000ff;
}
.tombol {
	font-family: Tahoma, Arial, Helvetica, sans-serif;
	font-size: 11px;
	color: #0000ff;
	background-color: #C9E1FB;
	padding: 2px;
	border: 1px solid #0000ff;
}-->*/
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->

// OnBlur OnFocus
var user = 'Username';
var pass = 'Password';
window.onload = function(){
    document.getElementById('username').value=user;
    document.getElementById('username').style.color = "#666666";
    document.getElementById('password').value=pass;
    document.getElementById('password').style.color = "#666666";
}

function tbFocus(textbox){
    if(textbox.value == user){
        textbox.value ="";
        textbox.style.color="#000000";
    }
    if(textbox.value == pass){
        textbox.value ="";
        textbox.style.color="#000000";
    }
}

function tbBlur(textbox){
    if(textbox.value == ""){
        textbox.value =user;
        textbox.style.color="#666666";
    }
    if(textbox.value == ""){
        textbox.value =pass;
        textbox.style.color="#666666";
    }
}
</script>
<?php
if(isset($HTTP_COOKIE_VARS["users_resolution"]))
$screen_res = $HTTP_COOKIE_VARS["users_resolution"];
else //means cookie is not found set it using Javascript
{
?>
<script language="JavaScript" type="text/JavaScript">
<!--
writeCookie();

function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie

//location = 'screen.php';
}
//-->
</script>
<?php
}
$xSplit = explode("x",$screen_res);
$resW = $xSplit[0];
$resH = $xSplit[1];

$_SESSION['wkurang'] = 195;
$_SESSION['hkurang'] = 470;

$_SESSION['w'] = $resW;
$_SESSION['h'] = $resH;

$_SESSION['wscrollgrid'] = $resW-183;
$_SESSION['hscrollgrid'] = $resH-480;

$_SESSION['wscrolldetail'] = $resW-165;
$_SESSION['hscrolldetail'] = $resH-410;

$_SESSION['wtblprint'] = $resW - 130;

//echo $_SESSION['wscrollgrid']."---";
?>
</head>
<body id="login">
<div class="box box-50 altbox">
			<div class="boxin">
				<div class="header">
				</div>
	   <form name="form1" method="post">
       <div class="inner-form">
						<div class="msg msg-info">
							<p>Masukan <strong>Username</strong> dan <strong>Password</strong> Anda, kemudian pilih tombol <strong>Login</strong> untuk masuk ke sistem.</p>
						</div><div id="gembok"><img src="css/img/key.png" width="60px" /></div>
    <table cellspacing="0">
			<tr>
                <th><label for="some1">Username:</label></th>
                <td><input class="txt" id="username" name="username" type="text" onFocus="javascript:tbFocus(this)" onBlur="javascript:tbBlur(this)" style="color:#000000"/></td>
            </tr>
                <tr>
						<th><label for="some3">Password :</label></th>
                        <td><input class="txt pwd" id="password" name="password" type="password" onFocus="javascript:tbFocus(this)" onBlur="javascript:tbBlur(this)" style="color:#000000"/></td>
                </tr>
                    <tr>
								<th></th>
                <td class="tr proceed">
                        <input type="submit" name="Submit" value="Login" class="button" />
                        <input name="Submit2" class="button" type="reset" value="Reset" />
                </td>
                    </tr>
    </table>
        </div>
	       </form>
      </div>
    </div>
</body>



<!--<body bgcolor="#88BAF7" leftmargin="0" topmargin="0">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="680" height="350" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
          <td height="136" width="673" style="border: 2px solid blue;"><img src="gambar/SIM-PAJAK-login2.jpg" width="675" height="145"></td>
        <tr>
          <td height="50"><img src="gambar/atas1.gif" width="85" height="50"><img src="gambar/atas2.gif" width="85" height="50"><img src="gambar/atas3.gif" width="85" height="50"><img src="gambar/atas4.gif" width="85" height="50"><img src="gambar/atas5.gif" width="85" height="50"><img src="gambar/atas6.gif" width="85" height="50"><img src="gambar/atas7.gif" width="85" height="50"><img src="gambar/atas8.gif" width="85" height="50"></td>
        </tr>
        <tr>
          <td height="50"><img src="gambar/atas9.gif" width="85" height="50"><img src="gambar/atas10.gif" width="85" height="50"><img src="gambar/atas11.gif" width="85" height="50"><img src="gambar/atas12.gif" width="85" height="50"><img src="gambar/atas13.gif" width="85" height="50"><img src="gambar/atas14.gif" width="85" height="50"><img src="gambar/atas15.gif" width="85" height="50"><img src="gambar/atas16.gif" width="85" height="50"></td>
        </tr>
        <tr>
          <td height="42"><img src="gambar/atas17.gif" width="85" height="42"><img src="gambar/atas18.gif" width="85" height="42"><img src="gambar/atas19.gif" width="85" height="42"><img src="gambar/atas20.gif" width="85" height="42"><img src="gambar/atas21.gif" width="85" height="42"><img src="gambar/atas22.gif" width="85" height="42"><img src="gambar/atas23.gif" width="85" height="42"><img src="gambar/atas24.gif" width="85" height="42"></td>
        </tr>
        <tr>
          <td height="208" background="gambar/bg-login.gif"><table border="0" cellpadding="15" cellspacing="0" width="100%">
              <tbody>
                <tr>
                  <td align="left"><div class="title">Member Login</div></td>
                </tr>
                <tr>
                  <td><table border="0" align="center" cellpadding="2" cellspacing="0" class="tbody">
                      <form name="form1" method="post" action="index.php">
                        <tbody>
                          <tr>
                            <td align="right">Username</td>
                            <td><div align="center">:</div></td>
                            <td align="left"><input name="username" id="username" type="text" class="field" onFocus="javascript:tbFocus(this)" onBlur="javascript:tbBlur(this)" style="color:#000000"></td>
                          </tr>
                          <tr>
                            <td align="right">Password</td>
                            <td><div align="center">:</div></td>
                            <td align="left"><input name="password" id="password" type="password" class="field" onFocus="javascript:tbFocus(this)" onBlur="javascript:tbBlur(this)" style="color:#000000"></td>
                          </tr>
                          <tr>
                            <td></td>
                            <td></td>
                            <td align="left"><input name="Submit" class="field" value="Submit" type="submit">
                                <input name="Submit2" class="field" value="Cancel" type="reset"></td>
                          </tr>
                        </tbody>
                      </form>
                    </table></td>
                </tr>
              </tbody>
            </table></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>-->
</html>
